<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>我的</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <link rel="shortcut icon" href="/static/favicon.ico">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="stylesheet" href="/static/css/sm.min.css">
    <link rel="stylesheet" href="/static/css/sm-extend.min.css">
    <!--icon css-->
    <link rel="stylesheet" href="/static/css/icon-style.css">


    <style>
        .list-block {
            margin: .4rem 0 !important;
        }

        a {
            color: gray;
        }
    </style>
</head>

<body>
<header class="bar bar-nav">
    <h1 class="title">我的</h1>
</header>

<div class="content">
    <!-- 头部信息-->
    <div class="list-block media-list">
        <ul>
            <li>
                <div class="item-link item-content"  id="headInfo" >
                    <div class="item-media"><img
                            src=""
                            onerror="this.src='/static/img/loadFail.png';this.onerror='null'"
                            style='width: 4rem;height: 4rem; border-radius: 100%'></div>
                    <div class="item-inner" onclick="loginPage()">
                        <div class="item-title-row" style="font-size: 1.5rem">
                            <div class="item-title">未登录</div>
                        </div>
                        <div class="item-subtitle">点击登录</div>
                    </div>
                </div>
            </li>
        </ul>
    </div>

    <!-- 操作信息-->
    <div class="list-block">
        <ul>

            <li class="item-content item-link" onclick="toPage('class')">
                <div class="item-media"><i class="icon icon-f7"></i></div>
                <span class="icon-star-full" style="padding:0  .5rem"></span>
                <div class="item-inner">
                    <div class="item-title">我的兴趣班</div>
                     
                </div>
            </li>
            <li class="item-content item-link" onclick="toPage('studyPro')">
                <div class="item-media"><i class="icon icon-f7"></i></div>
                <span class="icon-books" style="padding: 0 .45rem"></span>
                <div class="item-inner">
                    <div class="item-title">我的学习进度</div>
                </div>
            </li>

            <li class="item-content item-link prompt-ok">
                <div class="item-media"><i class="icon icon-f7"></i></div>
                <span class="icon-file-text" style="padding:0  .5rem"></span>
                <div class="item-inner">
                    <div class="item-title ">修改密码</div>
                </div>
            </li>
        </ul>
    </div>


    <div id="btn"></div>

    <nav class="bar bar-tab">
        <a class="tab-item " href="/page/indexPage">
            <span class="icon icon-home"></span>
            <span class="tab-label">首页</span>
        </a>
        <a class="tab-item active" href="/page/setting">
            <span class="icon icon-user"></span>
            <span class="tab-label">我的信息</span>
        </a>
    </nav>

</div>

</div>

<script type='text/javascript' src='/static/lib/zepto/zepto.min.js' charset='utf-8'></script>
<script type='text/javascript' src='/static/js/sm.min.js' charset='utf-8'></script>
<script type='text/javascript' src='/static/js/sm-extend.min.js' charset='utf-8'></script>
<script type='text/javascript' src='/static/js/deatilPage.js' charset='utf-8'></script>

<script>
    let userInfo = JSON.parse(localStorage.getItem('userInfo'));

    $(function () {
        if(userInfo){
            updateUserInfo();
        }else {

        }



    });

    $(document).on('click','.prompt-ok', function () {
        $.prompt('请输入新密码', function (value) {
            setTimeout(function () {
                $.alert('修改成功');
                setTimeout(function () {
                    loginPage();
                },200)
            },500)
        });
    });


    //更新用户信息
    function updateUserInfo(){

        var re =
            "<div class=\"item-media\" ><img\n" +
            "                            src='"+userInfo.icon+"' \n" +
            "                            onerror=\"this.src='/static/img/loadFail.png';this.onerror='null'\"\n" +
            "                            style='width: 4rem;height: 4rem; border-radius: 100%'></div>\n" +
            "                    <div class=\"item-inner\" >\n" +
            "                        <div class=\"item-title-row\" style=\"font-size: 1.5rem\">\n" +
            "                            <div class=\"item-title\">"+userInfo.name+"</div>\n" +
            "                        </div>\n" +
            "                        <div class=\"item-subtitle\">"+userInfo.intro+"</div>\n" +
            "                    </div>"
        $('#headInfo').html(re)
        var re1 =
            "    <div class=\"button button-fill\" onclick=\"logout()\"\n" +
            "       style=\"height: 2rem;line-height:2rem;width: 92%;margin: 1rem auto;font-size: .9rem\">退出登录</div>";
        $('#btn').html(re1)
    }


    //登录与登出
    function logout() {
        if (!userInfo||userInfo == {}) {
            loginPage();
        } else {
            localStorage.setItem('userInfo', null);
            window.location.reload();
        }
    }

    function toPage(url) {
        window.location.href=url;
    }



</script>
</body>

</html>